package com.kolaxy.eurekaclient;/*
 * 包    名:  com.kolaxy.eurekaclient
 * 描    述:  <描述>
 * 修 改 人:  zhourunjin
 * 修改时间:  2018/9/2
 */

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Random;

@RestController
public class HelloController {

    private final Logger logger = LoggerFactory.getLogger(HelloController.class);

    @Autowired
    private DiscoveryClient client;

    @RequestMapping(value = "hello",method = RequestMethod.GET)
    public String index() throws InterruptedException {

        int sleepTime = new Random().nextInt(3000);
        logger.info("/hello:time{}",sleepTime);
        Thread.sleep(sleepTime);
//        throw new RuntimeException();
        return "a";
    }

    @RequestMapping(value = "hello1",method = RequestMethod.GET)
    public String hello(@RequestParam String name){
        return "Hello "+name;
    }

    @RequestMapping(value = "hello2",method = RequestMethod.GET)
    public String hello(@RequestHeader String name,@RequestHeader Integer age){

        return name+"___"+age;
    }

}
